package MOLE.App;

import MOLE.*;

/** 
 Tsaipyao ��ժҪ˵����
*/
public class Tsaipyao
{
	private static String span0 = "-"; //��Ʊ��λ��
	private static String span1 = "|"; //��Ʊλ������
	private static String span2 = "@"; //��Ʊע������

//		//��ѡ��ʽ
//		private static Regex SingleSelectOne = new Regex(  GetRegexMultiStr(1,1) );
// 		private static Regex SingleSelectTwo = new Regex(  GetRegexMultiStr(1,2) );
//		private static Regex SingleSelect3 = new Regex(  GetRegexMultiStr(1,3) );
//		private static Regex SingleSelect4 = new Regex(  GetRegexMultiStr(1,4) );
//		private static Regex SingleSelect5 = new Regex(  GetRegexMultiStr(1,5) );
//		//��ѡ��ʽ
//		static Regex MultiSelect1 =  new Regex(  GetRegexMultiStr(2,1) );
//		static Regex MultiSelect2 = new Regex(  GetRegexMultiStr(2,2) );
//		static Regex MultiSelect3 = new Regex(  GetRegexMultiStr(2,3) );
//		static Regex MultiSelect4 =  new Regex(  GetRegexMultiStr(2,4) );
//		static Regex MultiSelect5 =  new Regex(  GetRegexMultiStr(2,5) );


	public Tsaipyao()
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
	}

	//�õ���׼Ͷע(������ѡ�����)��ע��Ʊ�ĸ�ʽ
	 private static String GetRegexStr(int selectType, int Statr)
	 {
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#region
		String span = "";
		if (selectType == 1) //single
		{
		}
		else
		{
			span = "+";
		}
		String s = "";
		s = "^";
		int j = Statr;
		for (int i = 0;i < 5 - j;i++)
		{
			s = s + "[" + span0 + "][\\" + span1 + "]";
		}
		for (int i = 0;i < j;i++)
		{
			if (i + 1 < j)
			{
				s = s + "[0-9]" + span + "[\\" + span1 + "]";
			}
			else
			{
				s = s + "[0-9]" + span;
			}
		}
		s = s + "$";
		return s;
//C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
			///#endregion
	 }


	//�õ���׼Ͷע(������ѡ�����)��ע��Ʊ�ĸ�ʽ
	 private static String GetRegexMultiStr(int selectType, int Statr)
	 {
		String s = GetRegexStr(selectType, Statr);
		s = tangible.DotNetToJavaStringHelper.trim(s, '^');
		s = tangible.DotNetToJavaStringHelper.trim(s, '$');

	  // string r="(@para)|((@para@)+@para)";
	   String r = "(@para@span)*@para";
		r = r.replace("@span",span2);
		r = r.replace("@para",s);
		r = "^" + r + "$";
		return r;
	 }




	//��Ʊ�ĸ�ʽ�Ƿ���Ч
	public static boolean IsRegexOk(int selectType, int start, String inputData)
	{
		Match m = (new Regex(GetRegexMultiStr(selectType, start))).Match(inputData);
		return m.Success;
	}


	////��Ʊ�ĸ�ʽ�Ƿ���Ч
	public static boolean IsRegexOk(int playid, String inputData)
	{

		switch (playid)
		{
			case 50120001: //ʱʱ�ʵ�ѡ����
				return IsRegexOk(1, 5, inputData);
			 case 50120002: //ʱʱ�ʵ�ѡ3��  //NO 4 START //4 IS NOT GOOD FOR
				return IsRegexOk(1, 3, inputData);
			case 50120003:
				return IsRegexOk(1, 2, inputData);
			case 50120004:
				return IsRegexOk(1, 1, inputData);


			//ZUHA
			case 50120011: //ʱʱ���������
				return IsRegexOk(2, 5, inputData);
			case 50120012: //ʱʱ�����3��  //NO 4 START //4 IS NOT GOOD FOR
				return IsRegexOk(2, 3, inputData);
			case 50120013:
				return IsRegexOk(2, 2, inputData);
			case 50120014:
				return IsRegexOk(2, 1, inputData);


			//HEZHI
			case 50120005:
				return IsRegexOk(3, 2, inputData);
				//break;
			case 50120006:
				return IsRegexOk(3, 2, inputData);
				//break;




			default:
				return false;
		}

	}



}